Skip to content

Support dependencies that supply a task parameter's value from Annotated metadata - #591

Merged
chrisguidry merged 5 commits into
mainfrom
annotated-providers
Nov 6, 2026
Merged

chrisguidry merged 5 commits into
mainfrom
annotated-providers

Conversation

@chrisguidry

Copy link
Copy Markdown
Owner

uncalled-for 0.6.0 resolves db: Annotated[Connection, Depends(get_db)] like a Depends(get_db) default, and adds Provided so the parameter stays optional for type-checked callers such as docket.add(task)(...). Docket's contextual dependencies (CurrentDocket, CurrentWorker, CurrentExecution, TaskKey, TaskLogger) are now Providers, so they work as metadata too, and Provided is exported from docket.

DB = Annotated[Connection, Depends(get_db)]

async def update_user(user_id: int, db: DB = Provided) -> None: ...

await docket.add(update_user)(user_id=1)

Docket bound each execution's arguments with signature.bind, which fails when a caller leaves out a required Annotated parameter. A ConcurrencyLimit on a sibling argument then raised TypeError, a parameter strike was silently skipped, and TaskArgument lost positional arguments. Those reads now use bind_partial, and compact_signature counts Annotated providers as dependencies in the worker's startup log.

Stacked on #590, which moves docket to Python 3.11 through 3.15. Follows chrisguidry/uncalled-for#23 and chrisguidry/uncalled-for#24.

🤖 Generated with Claude Code

https://claude.ai/code/session_01P7t1QchSu9EFNKhYMZPedt

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-06T01:05:14.061588Z f41656e Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chrisguidry

Copy link
Copy Markdown
Owner Author

@twavv this carries your Annotated dependencies from uncalled-for#23 into docket, plus the Provided default from uncalled-for#24 so docket.add(task)(...) still type-checks. Would you take a look?

@read-the-docs-community

read-the-docs-community Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Documentation build overview

📚 docket | 🛠️ Build #35686204 | 📁 Comparing f41656e against latest (e14b5a4)

  🔍 Preview build  

3 files changed
± api-reference/index.html
± dependency-injection/index.html
± getting-started/index.html

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 249c0fc4d4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread python/src/docket/strikelist.py Resolved
@chrisguidry

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5c33ebde71

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread python/src/docket/execution.py Resolved
@chrisguidry

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f0a2c5abe4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docs/dependency-injection.md Resolved
@chrisguidry
chrisguidry added this pull request to stack #592 November 6, 2026 00:28
Base automatically changed from python-3-11-to-3-15 to main November 6, 2026 00:28
chrisguidry and others added 4 commits November 5, 2026 19:32
…ted metadata

uncalled-for 0.6.0 resolves `db: Annotated[Connection, Depends(get_db)]` like a `Depends(get_db)` default, and adds `Provided` so the parameter stays optional for type-checked callers such as `docket.add(task)(...)`. Docket's contextual dependencies (CurrentDocket, CurrentWorker, CurrentExecution, TaskKey, TaskLogger) are now Providers, so they work as metadata too, and `Provided` is exported from docket.

Docket bound each execution's arguments with `signature.bind`, which fails when a caller leaves out a required Annotated parameter. A ConcurrencyLimit on a sibling argument then raised TypeError, a parameter strike was silently skipped, and TaskArgument lost positional arguments. Those reads now use `bind_partial`, and `compact_signature` counts Annotated providers as dependencies in the worker's startup log.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P7t1QchSu9EFNKhYMZPedt
…guments

A partial bind also accepted a call that left out an ordinary required argument, so a strike on another argument marked that malformed call STRUCK and hid it, where a full bind had let the task run and raise TypeError. Execution.bind_arguments now binds partially but raises TypeError for any missing parameter that no dependency supplies, and the strike check, ConcurrencyLimit's argument lookup, and the worker's provided-argument map all use it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P7t1QchSu9EFNKhYMZPedt
The worker's startup log read Annotated metadata itself and missed the bare-class shorthand, `Annotated[str, CurrentTenant]`, so it listed that parameter as one the caller passes. compact_signature now takes the task and collapses whatever get_dependency_parameters reports, which also covers type aliases and string annotations.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P7t1QchSu9EFNKhYMZPedt
The worker found lifecycle classes in parameter defaults and in the dependencies that wrap the call, so a Provider declared only as metadata, such as `Annotated[str, Pool()]`, never had its worker_lifecycle entered. It now scans every dependency that get_dependency_parameters reports, which covers both forms.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P7t1QchSu9EFNKhYMZPedt
@chrisguidry

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

Unknown error
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chrisguidry

Copy link
Copy Markdown
Owner Author

@codex review

@twavv

twavv commented Nov 6, 2026

Copy link
Copy Markdown

I'm not familiar with Docket, but uhhh,,, you get a general LGTM from me. 😎

seal-of-approval-thumbs-up-gif

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 24032fc7d5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread python/src/docket/execution.py Resolved
Comment thread python/src/docket/execution.py Resolved
ConcurrencyLimit read its argument from the caller's call alone, so a limit on a parameter that a dependency supplies, such as `tenant: Annotated[str, Depends(get_tenant), ConcurrencyLimit(1)] = Provided`, keyed every task on the Provided sentinel, and a `Depends(...)` default keyed on the dependency object; either way every tenant shared one slot. It now asks the resolution frame for the argument, which returns the caller's value, the value a dependency supplies, or the default.

Execution.get_argument had no other caller and gave the same wrong answer for dependency-supplied parameters, so it is gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P7t1QchSu9EFNKhYMZPedt
@chrisguidry

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: f41656e929

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chrisguidry
chrisguidry merged commit 11aefa4 into main Nov 6, 2026
55 checks passed
@chrisguidry
chrisguidry deleted the annotated-providers branch November 6, 2026 02:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants